package Hot100.Medium.HeapAndStack;

import java.util.PriorityQueue;

public class LC215_findKthLargestInArray {

    public int findKthLargest(int[] nums, int k){
        PriorityQueue<Integer> heap = new PriorityQueue<>();
        for(int num : nums){
            heap.add(num);
            if(heap.size() > k){
                heap.poll();
            }
        }
        return heap.peek();
    }
}
